/**
 * 
 */
package hr.fer.zemris.rznu.model.betting;

import java.util.Set;
import javax.persistence.Id;


import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;


import hr.fer.zemris.rznu.model.dto.betting.BettingSlipDTO;
import hr.fer.zemris.rznu.model.factories.ConverterFromDTOFactory;
import hr.fer.zemris.rznu.model.user.User;

/**
 * @author Dajan
 *
 */
@Entity
@Table(name="BETTING_SLIP")
public class BettingSlip {

	@Id
	@GeneratedValue
	private Integer Id;
	
	@Column(name="slipId", unique=true, nullable=false)
	private Long slipId;
	
	@Column(name="userID", unique=false, nullable=false)
	private Long userID;
	
	@Column(name="userBet", unique=false, nullable=false)
	private Double userBet;
	
	@Column(name="successfulEvent", unique=false, nullable=true)
	private Boolean successfulEvent;
	
	@Column(name="successfulSlip", unique=false, nullable=true)
	private Boolean successfulSlip;
	
	@Column(name="possibleWin", unique=false, nullable=false)
	private Double possibleWin;
	
	@ManyToOne(optional=false)
	private User user;
	
	@OneToMany(mappedBy="slip")
	private Set<BettingEvent> bettingEvent;
	
	
	
	public BettingSlip(){
		
	}
	
	public BettingSlip(BettingSlipDTO bettingSlipDto){
		
		this.slipId = bettingSlipDto.getSlipId();
		this.userID = bettingSlipDto.getUserID();
		this.userBet = bettingSlipDto.getUserBet();
		this.successfulEvent = bettingSlipDto.getSuccessfulEvent();
		this.successfulSlip = bettingSlipDto.getSuccessfulSlip();
		this.possibleWin = bettingSlipDto.getPossibleWin();
		this.user = new User(bettingSlipDto.getUserDTO());
		this.bettingEvent = ConverterFromDTOFactory.getBettingEvents(bettingSlipDto.getBettingEventsDTO());
		
	}

	public Integer getId() {
		return Id;
	}

	public void setId(Integer id) {
		Id = id;
	}

	public Long getSlipId() {
		return slipId;
	}

	public void setSlipId(Long slipId) {
		this.slipId = slipId;
	}

	public Long getUserID() {
		return userID;
	}

	public void setUserID(Long userID) {
		this.userID = userID;
	}

	public Double getUserBet() {
		return userBet;
	}

	public void setUserBet(Double userBet) {
		this.userBet = userBet;
	}

	public Boolean getSuccessfulEvent() {
		return successfulEvent;
	}

	public void setSuccessfulEvent(Boolean successfulEvent) {
		this.successfulEvent = successfulEvent;
	}

	public Boolean getSuccessfulSlip() {
		return successfulSlip;
	}

	public void setSuccessfulSlip(Boolean successfulSlip) {
		this.successfulSlip = successfulSlip;
	}

	public Double getPossibleWin() {
		return possibleWin;
	}

	public void setPossibleWin(Double possibleWin) {
		this.possibleWin = possibleWin;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Set<BettingEvent> getBettingEvent() {
		return bettingEvent;
	}

	public void setBettingEvent(Set<BettingEvent> bettingEvent) {
		this.bettingEvent = bettingEvent;
	}
	
	
	
}
